package Day13.可变参数;

/**
 * @author HYHwtx
 * @version 1.0
 * @date 2022/2/19 15:32
 */
public class Demo03 {
    public static void main(String[] args) {
        Demo03 q = new Demo03();
        System.out.println(Demo03.Re("宋江", 90.2, 89.3));
        System.out.println(Demo03.Re("武松", 90.2, 89.3, 77.3));
        System.out.println(Demo03.Re("林冲", 90.2, 89.3, 100, 33.4, 98.3));

    }


    public static String Re(String name, double... nums) {
        String str = "姓名：" + "\t" + name;
        double score = 0.0;//总分
        for (int i = 0; i < nums.length; i++) {
            score += nums[i];
            str += nums[i] + "\t";
        }
        //sum得到
        str += " 总分=" + score;
        return str;
    }
}

